package instrumentation;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;


public class BlockMethodEntry implements Serializable {

	private static final long serialVersionUID = -3816067359592430951L;

	private final BlockClass clazz;
	private final String fullQualifiedName;
	private  Set<Condition> branches=new HashSet<Condition>() ;
	private final boolean isPrivate;
	public BlockMethodEntry(BlockClass clazz, String fullQualifiedName,boolean isPrivate) {
		this.fullQualifiedName = fullQualifiedName;
		this.clazz = clazz;
		this.isPrivate=isPrivate;
	}
	public boolean isPrivate(){
		return this.isPrivate;
		
	}
	public void addCondition(Condition br) {
		branches.add(br);
	}
	public Set<Condition> getCondition() {
		Set<Condition> branches=this.branches;
		List orders = new ArrayList(branches);
		Collections.sort(orders,Condition.SORT_MEMBERS_BY_BRANCHID);
		return new HashSet<Condition>(orders);
	}

	public String getFullQualifiedName() {
		
		return fullQualifiedName;
	}

	public BlockClass getClazz() {
		return clazz;
	}
	@Override
	public String toString(){
		return this.getFullQualifiedName();
	}
	@Override
	public int hashCode(){
		int hashcode = fullQualifiedName.hashCode();
		return hashcode;
	}


	    public boolean equals(Object obj){
	        if (obj instanceof BlockMethodEntry) {
	        	BlockMethodEntry pp = (BlockMethodEntry) obj;
	            return (pp.getFullQualifiedName().equals(this.getFullQualifiedName()));
	        } else {
	            return false;
	        }
	    }
}
